package com.twu.biblioteca.library.item;

import com.twu.biblioteca.control.Strings;

public class Movie extends LibraryItem implements Comparable {

    private int year;
    private String director;
    private int rating;

    public Movie(int id, String name, String director, int year, int rating) {
        super(id, name);
        this.year = year;
        this.director = director;
        this.rating = rating;
    }

    public int getId() {
        return id;
    }

    public int getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    public String getRating() {
        if (rating == 0) {
            return "unrated";
        } else {
            return Integer.toString(rating);
        }
    }

    public void getHeader(){
        System.out.println(Strings.movieHeader1);
        System.out.println(Strings.movieHeader2);
        System.out.println(Strings.movieHeader3);
    }

    public void printItem(){
        System.out.println(String.format("%8d   %20s   %20s   %20s   %20s", getId(), getName(), getDirector(), getYear(), getRating()));
    }

    @Override
    public int compareTo(Object object) {
        Movie movie = (Movie) object;
        return Integer.toString( this.getId() ).compareTo( Integer.toString( movie.getId() ) );
    }
}
